// 写Yaru主题特供版的登录界面

// 关闭VSCode非必要报警
// ignore_for_file: unused_element, non_constant_identifier_names, camel_case_types

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:project_award_statistics/pages/desktop_adwaita/login_page/login_page.dart';
import 'package:project_award_statistics/utils/my_yaru_buttons/my_yaru_button_normal.dart';
import 'package:yaru/yaru.dart';

class WelcomePage_Desktop extends StatefulWidget 
  {
    const WelcomePage_Desktop({super.key});

    @override
    State<WelcomePage_Desktop> createState() => _WelcomePage_DesktopState();
  }

class _WelcomePage_DesktopState extends State<WelcomePage_Desktop> with TickerProviderStateMixin {
  
  // 初始化动画总线控制器1
  // 由于控件1动画是淡入淡出的,所以不初始化,放在这里作为提醒
  // 故只初始化动画总线控制器2
  late AnimationController _animationController_widget2;
  bool _isVisible=false;  // 控制淡入效果控件最开始不可见

  @override
  void initState()    // 覆写父类构造函数 
  {
    super.initState();
    _animationController_widget2 = AnimationController(
      duration: Duration(seconds: 1),     // 设置动画持续时间
      vsync: this,
    );
   
    Timer(Duration(seconds:1),(){
      setState(() {
        _isVisible=!_isVisible;
      });
      // 动画,启动!
      Timer(Duration(seconds: 1),(){
        _animationController_widget2.forward();
      });   
    });   
  }

  @override
  void dispose() 
    {
      super.dispose();
      _animationController_widget2.stop();
      _animationController_widget2.dispose();
    }

  @override
  Widget build(BuildContext context) {

    // 初始化程序总框架
    return Scaffold(
      backgroundColor: Colors.white, // 设置背景颜色
      body: Padding(
        // 先设置总体边距
        padding: EdgeInsets.only(top: 0, left: 35, right: 50),
        child: Row(
          // 总体列式布局为了搞点花活 ）
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset(
                      // 显示校徽
                      "lib/images/northwest_minzu_university_icon.png",
                      width: 180,
                      height: 180,
                    ),
                    const SizedBox(width: 30),
                    Column(
                      children: [
                        Text(
                          "西北民族大学",
                          style:    // 设计字体样式
                              TextStyle(
                            color: Colors.black,
                            fontSize: 45,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                        const SizedBox(height: 15),    // 设定两行文字间间距 
                        Text(
                          "电子设计工作室",
                          style:TextStyle(     // 设计字体样式
                            color: Colors.black, 
                            fontSize: 30,
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
                const SizedBox(height: 80),
                Text(
                  "个人奖项查询软件",
                  style: TextStyle(
                    color: YaruColors.titleBarDark,
                    fontSize: 40,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                const SizedBox(height: 80),
              ],
            ),
            const SizedBox(width: 80), // 设置控件边距
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                AnimatedOpacity(
                  opacity: _isVisible ? 1.0 : 0.0, 
                  duration: Duration(seconds: 2),
                  child: Text(
                    "欢迎！让我们从这里开始吧",
                    style: TextStyle(
                      color: Colors.black,
                      fontSize: 40,              
                    ),
                  ),
                ),
                const SizedBox(height: 70,),
                SlideTransition(   // 设置按钮
                  position: Tween<Offset>(
                    begin: Offset(4.0, 0),
                    end: Offset.zero,
                  ).animate(
                    CurvedAnimation(
                      parent: _animationController_widget2,
                      curve: Curves.easeInOut,
                    ),
                  ),
                  child: SizedBox(
                    height: 60,
                    width: 150,
                    child: MyYaruButton_Normal(
                      text: "点击进入", 
                      onPressed: (){
                        Navigator.pushReplacement(   // 进入登录页面
                          context, 
                          MaterialPageRoute(
                            builder: (context)=>PopScope(                   
                              canPop: false,
                              child: LoginPage_Desktop(), 
                            ),
                          ),
                        );
                      },
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
